<template>
	<view class="main-box">
		<view class="navigator-bar" :style="{'padding-top': safeTop + 'px'}">
			<image class="back-img" src="/static/backArrow2.png" @click="back()"></image>
			<view class="tab-box">
				<view :class="index === 0 ? 'choose-tab': 'unchoose-tab'" @click="changeIndex(0)">
					<text>关注</text>
					<view :class="index === 0 ? 'choose-box': 'unchoose-box'"></view>
				</view>
				<view :class="index === 1 ? 'choose-tab': 'unchoose-tab'" @click="changeIndex(1)">
					<text>粉丝</text>
					<view :class="index === 1 ? 'choose-box': 'unchoose-box'"></view>
				</view>
			</view>
		</view>
		<swiper class="index-swiper-box" :indicator-dots="false" :current="index" disable-touch="true" :duration="0"
			:style="{'height': `calc(100% - ${safeTop}px - 86rpx)`}">
			<swiper-item>
				<user-list :type="0" :userId="userId ? userId : null"></user-list>
			</swiper-item>
			<swiper-item>
				<user-list :type="1" :userId="userId ? userId : null"></user-list>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import userList from '@/components/userList.vue'

	export default {
		data() {
			return {
				index: 0,
				safeTop: 0,
				userId: null
			};
		},
		onLoad(q) {
			this.safeTop = this.$safeTop;
			this.index = +q.type;
			if (q.userId) {
				this.userId = +q.userId;
			}
		},
		components: {
			userList
		},
		methods: {
			back() {
				uni.navigateBack();
			},
			changeIndex(index) {
				this.index = index;
			}
		}
	}
</script>

<style lang="scss">
	.main-box {
		width: 100vw;
		height: 100vh;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		overflow: hidden;

		.navigator-bar {
			width: 100vw;
			height: 86rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			position: relative;

			.back-img {
				width: 24rpx;
				height: 40rpx;
				margin-left: 42rpx;
				z-index: 999;
			}

			.page-title {
				font-size: 38rpx;
				font-weight: bold;
				color: #222222;
				position: absolute;
				width: 100vw;
				line-height: 38rpx;
				text-align: center;
			}

			.tab-box {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				position: absolute;

				.choose-tab {
					font-size: 40rpx;
					font-weight: bold;
					color: #222222;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 0 25rpx 0 25rpx;
				}

				.unchoose-tab {
					font-size: 32rpx;
					font-weight: 400;
					color: #222222;
					display: flex;
					flex-direction: column;
					align-items: center;
					padding: 0 25rpx 0 25rpx;
				}

				.choose-box {
					width: 40rpx;
					height: 8rpx;
					background: #FF5E2E;
					border-radius: 4rpx;
				}

				.unchoose-box {
					width: 40rpx;
					height: 8rpx;
				}
			}
		}

		.index-swiper-box {
			width: 100%;
		}
	}
</style>
